package com.nightsoul.springboottest2.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.nightsoul.springboottest2.domain.User;

@RestController
public class RedisUserController {
	private static final Logger LOGGER = LoggerFactory.getLogger(RedisUserController.class);

	@RequestMapping("/redis/user/{id}")
	@Cacheable(value="user-key")
	public User user(@PathVariable("id")Long id) {
		User user = new User("zhangsan", "zhangsan", "zhangsan@126.com", "zhangsan", "2017-07-29 11:10:36");
		user.setId(id);
		LOGGER.info("create user");
		return user;
	}
}
